// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var constant = require("constant");
	var databind = require("databind");
	var css_enterpriseDetail = require("./clientManage_authentication.css");
	var router = require("../hash/pageRouter");
	var flag = false;
	var enterpriseId;
	var Eqianbao;
	var mySignatureInfo;
	var promptTime;//e签宝预计审核完成时间
	var depositBank;
	var subbranch;
	var creditCard;
	var mobile;
	var auditState; 
	var auditState1;
	var id;
	var tools = require("tools");
	var tools = require("tools");
	var html_activeCard = require("../../enterprise/account/html_activeCard.html");
	var html_rebutReason = require("../../enterprise/account/html_rebutReason.html");
	var html_playMoney = require("../../enterprise/account/html_playMoney.html");
	var html_mobileInfo = require("../../enterprise/account/html_mobileInfo.html");
	var html_callBackSignature = require("./html_callBackSignature.html");
	var html_refuseSignature = require("./html_refuseSignature.html");
	var authentication; //认证状态
	var errorMessage; //认证驳回原因
	var enabled; //签章启用状态
	var modelType;
	var ii;
	var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var oData = {
		pageIndex: pageIndex,
		pageSize: pageSize,
		totalPageCount: totalPageCount,
		totalRecordCount: totalRecordCount,
		statementBeginDate: "",
		statementEndDate: "",
		statementNumber: "",
		receiptName: "",
		minSourceAmount: "",
		maxSourceAmount: "",
		financeNumber: ""
	};
	var init = function(page) {
		Eqianbao = page.params.Eqianbao;
		mySignatureInfo = page.params.mySignature;
		enterpriseId = page.params.enterpriseId;
		$(".nav_active").removeClass("nav_active1");
		$(".authenticationState").addClass("nav_active1");
		inquireEnterpriseDetail(enterpriseId);
		router.init();
		initEvent();
	};

	var initEvent = function() {
			//点击法人印章
		$("#li3Id").unbind("click").click(function() {
			changeCssSealType($(this), 1);
			
			inquireSealDetail(1, function(data){
				
			});
		});
		
		//默认显示企业印章
		inquireSealDetail(2, function(data){
			
		});
		
		//点击企业印章
		$("#li2Id").unbind("click").click(function() {
			changeCssSealType($(this), 2);
			
			inquireSealDetail(2, function(data){
				
			})
		});
		
			//点击财务印章
		$("#li4Id").unbind("click").click(function() {
			changeCssSealType($(this), 3);
			
			inquireSealDetail(3, function(data){
				
			});
			
		});
		
			//点击其他印章
		$("#li5Id").unbind("click").click(function() {
			changeCssSealType($(this), 4);
			
			inquireSealDetail(4, function(data){
				
			});
		});
		
		/*$("#container3 .nextButton").unbind("click").click(function(){
			databind.submitDom($("#container3"), function(){
				alert("success");
				//router.route("account/enterpriseDetail.html?Eqianbao=" + 1);
			});
		});*/
		
		//判断企业是否进行企业资质认证
		/*if(auditState == 2 || auditState == 4) { //显示实名认证
			$(".certification").removeClass("none");
		}*/
		//判断实名认证点击
		if(Eqianbao != undefined && Eqianbao == 1 ) {
			enterpriseDetail();
		}
		
		//判断我的签章点击
		if(mySignatureInfo != undefined && mySignatureInfo == 1 ) {
			mySignatureCss();
		}
		//判断认证状态
		if(authentication != 3) { //
			$(".mySignatureInfo").hide();
		}
		if(authentication == 0 || authentication == undefined) { //未认证
			$("#span_stateInfo").text("未实名认证");
			$("#a_stateInfo").text("立即认证");
			$("#a_stateInfo").attr("class","authenticationNow");
		}else if(authentication == 5) { //认证驳回
			$("#span_stateInfo").text("实名被驳回");
			$("#a_stateInfo").text("查看驳回原因");
			$("#a_stateInfo").attr("href","javascript:void(0);");
			$("#a_stateInfo").attr("class","authenticationStateInfo");
		}else if(authentication == 2) { //已打款，输入审核金额
			$("#span_stateInfo").text("银行账号确认");
			$("#a_stateInfo").text("输入审核金额");
			$("#a_stateInfo").attr("href","javascript:void(0);");
			$("#a_stateInfo").attr("class","playMoneyStateInfo");
		}else if(authentication == 3) { //已认证
			$("#span_stateInfo").text("已认证");
			$("#a_stateInfo").text("查看认证信息情况");
			$("#a_stateInfo").attr("class","authenticationSuccess");
			$("#container2_Div .divImg1").children("img").attr("src","../../../res/png/rz_finish(1).png");
			$("#container2_Div").append("<a class='reAuthenticate' style='position:relative; top:10px; color:red;' href='javascript:void(0);'>重新认证</a>");
			
			$("#clientManage_authentication .reAuthenticate").unbind("click").click(function(){
				ii = layer.confirm('是否确认对该企业进行重新认证？', {
				  btn: ['确定','取消'] //按钮
				}, function(){
				  recertification(enterpriseId);
				}, function(){
				  
				});
			});
		}else if(authentication == 7) { //输入金额不正确，认证失败
			$("#span_stateInfo").text("银行账号确认错误");
			$("#a_stateInfo").text("查看错误原因");
			$("#a_stateInfo").attr("href","javascript:void(0);");
			$("#a_stateInfo").attr("class","failStateInfo");
		}else if(authentication == 1 || authentication == 6) { //实名待审核或打款中
			$("#span_stateInfo").text("实名待审核");
			$("#a_stateInfo").text("查看审核进度");
			$("#a_stateInfo").attr("href","javascript:void(0);");
			$("#a_stateInfo").attr("class","authenticationIng");
		}else if(authentication == 4) { //认证失败 
			$("#span_stateInfo").text("认证失败");
			$("#a_stateInfo").text("查看失败原因");
			$("#a_stateInfo").attr("href","javascript:void(0);");
			$("#a_stateInfo").attr("class","authenticationfailInfo");
		}
		
		if (base.getData("sid") == null) {
			location.href = "../login/login.html";
		}
		
		//查看认证驳回原因
		$(".authenticationStateInfo").unbind("click").click(function(){
			var ii = layer.open({
				  title: '驳回原因',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['430px', '330px'], //宽高
				  content: html_rebutReason,
				  btn: ['重新认证'],
				  yes: function(){
				  	layer.close(ii);
					  router.route("client/client_Eqianbao.html?enterpriseId=" + enterpriseId); 
				  }
				});
			$("#reason").text(errorMessage);
			var text = '<span id="span1"><img src="../../../res/png/u438.png" /><span>';
			$(".layui-layer-title").append(text);
			$(".layui-layer-title").css({"text-align":"center","font-size":"30px","height":"60px","padding-top":"6px","color":"red"});
			$("#span1").css({"float":"left","margin-left":"60px"});
			$("#reason").css({"margin-top":"80px","font-size":"25px","margin-left":"100px"});
			$(".layui-layer-btn0").css({"position":"relative","margin-top":"-60px","margin-right":"140px","width":"140px","height":"40px","text-align":"center","padding-top":"6px","font-size":"18px","background-color":"rgb(231,64,49)"});
		});
		
		//查看认证失败原因
		$(".authenticationfailInfo").unbind("click").click(function(){
			var ii = layer.open({
				  title: '认证失败原因',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['430px', '330px'], //宽高
				  content: html_rebutReason,
				  btn: ['重新认证'],
				  yes: function(){
				  	layer.close(ii);
					  router.route("client/client_Eqianbao.html?enterpriseId=" + enterpriseId); 
				  }
				});
			$("#reason").text(errorMessage);
			var text = '<span id="span1"><img src="../../../res/png/u438.png" /><span>';
			$(".layui-layer-title").append(text);
			$(".layui-layer-title").css({"text-align":"center","font-size":"30px","height":"60px","padding-top":"6px","color":"red"});
			$("#span1").css({"float":"left","margin-left":"60px"});
			$("#reason").css({"margin-top":"80px","font-size":"25px","margin-left":"100px"});
			$(".layui-layer-btn0").css({"position":"relative","margin-top":"-60px","margin-right":"140px","width":"140px","height":"40px","text-align":"center","padding-top":"6px","font-size":"18px","background-color":"rgb(231,64,49)"});
		});
		
		//实名待审核
		$(".authenticationIng").unbind("click").click(function(){
			var ii = layer.open({
				  title: '请耐心等待',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['430px', '330px'], //宽高
				  content: html_rebutReason,
				  btn: ['关闭'],
				  yes: function(){
					  layer.close(ii); 
				  }
				});
			$("#reason").text("我司将在"+ promptTime +"左右完成审核，审核结果将通过短信或邮件的方式通知到您；审核通过后，会向贵公司的对公账号汇入一笔1元以下的金额，注意查收。");
			var text = '<span id="span1"><img src="../../../res/png/u309.png" /><span>';
			$(".layui-layer-title").append(text);
			$(".layui-layer-title").css({"text-align":"center","font-size":"30px","height":"60px","padding-top":"6px"});
			$("#span1").css({"float":"left","margin-left":"60px"});
			$("#reason").css({"margin-top":"px","font-size":"px","margin-left":"px","padding":"20px","margin-top":"30px"});
			$(".layui-layer-btn0").css({"position":"relative","margin-top":"-60px","margin-right":"140px","width":"140px","height":"40px","text-align":"center","padding-top":"6px","font-size":"18px","background-color":"rgb(196,62,62)"});
		});
		
		//查看金额输入失败原因
		$(".failStateInfo").unbind("click").click(function(){
			var ii = layer.open({
				  title: '金额确认错误原因',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['430px', '330px'], //宽高
				  content: html_rebutReason,
				  btn: ['重新确认'],
				  yes: function(){
					  layer.close(ii);
					  playMoneyStateInfo();
				  }
				});
			$("#reason").text(errorMessage);
			var text = '<span id="span1"><img src="../../../res/png/u438.png" /><span>';
			$(".layui-layer-title").append(text);
			$(".layui-layer-title").css({"text-align":"center","font-size":"25px","height":"60px","padding-top":"6px","color":"red"});
			$("#span1").css({"float":"left","margin-left":"60px"});
			$("#reason").css({"margin-top":"80px","text-align":"center"});
			$(".layui-layer-btn0").css({"position":"relative","margin-top":"-60px","margin-right":"140px","width":"140px","height":"40px","text-align":"center","padding-top":"6px","font-size":"18px","background-color":"rgb(196,62,62)"});
		});
		
		//查看手机认证信息
		$(".mobileInfo").unbind("click").click(function(){
			var ii = layer.open({
				  title: '手机认证信息',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['430px', '330px'], //宽高
				  content: html_mobileInfo,
				  btn: ['关闭'],
				  yes: function(){
					  layer.close(ii);
				  }
				});
			$("#mobileDiv").text(mobile);
			$(".layui-layer-title").css({"text-align":"center","font-size":"25px","height":"60px","padding-top":"6px"});
			$(".layui-layer-btn0").css({"position":"relative","margin-top":"-60px","margin-right":"140px","width":"140px","height":"40px","text-align":"center","padding-top":"6px","font-size":"18px"});
		});
		
		//输入审核金额
		$(".playMoneyStateInfo").unbind("click").click(function(){
			playMoneyStateInfo();
		});
		
		$("#enterpriseDetail").on("change", "#creditCard", function(){
			var bn = tools.getBankName($(this).val());
			if (bn == ""){
				alert("未知开户行！");
			} else {
				$("#depositBank").val(bn);
			}
		});

		//实名认证
		$("#enterpriseDetail").on("click", ".certification", function() {
			enterpriseDetail();
		});
		
		//我的签章
		$("#enterpriseDetail").on("click", ".mySignatureInfo", function() {
			mySignatureCss();
		});

		$("#enterpriseDetail").on("click", ".moneyReceiptStatement", function() {
			$("#enterpriseDetail .d2").css("background", "url(../../../res/png/tab_bg2.png) center bottom no-repeat");
			$(".container").addClass("none");
			$(".container1").removeClass("none");
			tools.loadList("inquireReceiptMoneyStatementPageList.json", $("#receiptManageBody"), $("#receiptManageTpl"), oData, function() {
				$(".detail").unbind("click").click(function() {
					//router.route("insuranceManage/insuranceDetail.html?insuranceId=" + $(this).parents("tr").attr("insuranceId") + "&financeId=" + $(this).parents("tr").attr("financeId"));
				});
			});
		});
		
		$("#enterpriseDetail").on("click", ".moneyDisbursementStatement", function() {
			$("#enterpriseDetail .d2").css("background", "url(../../../res/png/tab_bg3.png) center bottom no-repeat");
//			$(".container").addClass("none");
//			$(".container1").removeClass("none");
//			tools.loadList("inquireReceiptMoneyStatementPageList.json", $("#receiptManageBody"), $("#receiptManageTpl"), oData, function() {
//				$(".detail").unbind("click").click(function() {
//					//router.route("insuranceManage/insuranceDetail.html?insuranceId=" + $(this).parents("tr").attr("insuranceId") + "&financeId=" + $(this).parents("tr").attr("financeId"));
//				});
//			});
		});
		
		//点击企业基本信息
		$(".clientManage_details1 .enterpriseInfo").on("click", function() {
			router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId, true);
		});

		$(".financeSituation").on("click", function() {
			router.route("client/clientManage_financeSituation.html?enterpriseId=" + enterpriseId);
		});

		//证明材料
		$(".financeEvidentiary").on("click", function() {
			router.route("client/clientManage_financeEvidentiary.html?enterpriseId=" + enterpriseId);
		});
		
		//点击企业基本信息
		$(".enterpriseInfo").on("click", function() {
			router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId, true);
		});
		
		//我的客户
		$(".financeBelongs").on("click", function() {
			router.route("client/clientManage_belongs.html?enterpriseId=" + enterpriseId);
		});
		
		//已认证，查看信息情况
		$(".authenticationSuccess").on("click", function() {
			router.route("client/client_Eqianbao.html?enterpriseId=" + enterpriseId);
		});
		
		//未认证
		$(".authenticationNow").on("click", function() {
			router.route("client/client_Eqianbao.html?enterpriseId=" + enterpriseId);
		});
		
		//审批同意
		$("#container3 .aggreButton").unbind("click").click(function(){
			var sealType = $("#container3 input[name=sealType]").val();
			var ii = layer.open({
			  title: '审批同意',
			  type: 1,
			  skin: 'layui-layer-rim', //加上边框
			  area: ['430px', '230px'], //宽高
			  content: html_refuseSignature,
			  btn: ['提交'],
			  yes: function(){
			  	$(".refuseSignatureBox input[name='id']").val(id);
				$(".refuseSignatureBox input[name='auditState']").val(true);
			  	databind.submitDom($(".refuseSignatureBox"), function(data) {
					if(data.status == 200) {
						layer.close(ii);
						base.alert(1, "审核成功");
						inquireSealDetail(sealType, function(data) {
							
						});
					}
			 	})
			  }
			})
		});
		
		//审批拒绝
		$("#container3 .refuseButton").unbind("click").click(function(){
			var sealType = $("#container3 input[name=sealType]").val();
			var ii = layer.open({
			  title: '审批拒绝',
			  type: 1,
			  skin: 'layui-layer-rim', //加上边框
			  area: ['430px', '230px'], //宽高
			  content: html_refuseSignature,
			  btn: ['提交'],
			  yes: function(){
			  	$(".refuseSignatureBox input[name='id']").val(id);
				$(".refuseSignatureBox input[name='auditState']").val(false);
			  	databind.submitDom($(".refuseSignatureBox"), function(data) {
					if(data.status == 200) {
						layer.close(ii);
						base.alert(1, "拒绝成功");
						inquireSealDetail(sealType, function(data) {
							
						});
					}
			 	})
			  }
			})
		});
		
		//重新制章
		$("#container3 .callBackSignature").unbind("click").click(function(){
			var sealType = $("#container3 input[name=sealType]").val();
			var ii = layer.open({
			  title: '重新制章',
			  type: 1,
			  skin: 'layui-layer-rim', //加上边框
			  area: ['430px', '230px'], //宽高
			  content: html_callBackSignature,
			  btn: ['提交'],
			  yes: function(){
			  	$(".callBackSignatureBox input[name='enterpriseId']").val(enterpriseId);
				$(".callBackSignatureBox input[name='sealType']").val(sealType);
			  	databind.submitDom($(".callBackSignatureBox"), function(data) {
					if(data.status == 200) {
						layer.close(ii);
						base.alert(1, "打回成功");
						inquireSealDetail(sealType, function(data) {
							if(data.datas[0].enabled) { //签章未启用
								$("#enabled").text("已启用！");
							} else {
								$("#enabled").text("该印章正在审核中，尚未启用！");
							}
						});
					}
			 	})
			  }
			})
		});
	}
	
	//重新认证
	var recertification = function(enterpriseId) {
		base.fnAjax({
			action: "recertification.json",
			async: false,
			oData: {
				enterpriseId: enterpriseId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "操作成功！");
					router.route("client/clientManage_authentication.html?enterpriseId=" + enterpriseId);
				} else {
					base.alert(3, data.message);
				}
			}
		});
	}
	
	//查询当前帐号企业明细
	var inquireEnterpriseDetail = function(enterpriseId) {
		base.fnAjax({
			action: "inquireEnterpriseDetail.json",
			async: false,
			oData: {
				enterpriseId: enterpriseId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					auditState = data.datas[0].auditState;
					mobile = data.datas[0].mobile;
					depositBank = data.datas[0].depositBank;
					subbranch = data.datas[0].subbranch;
					creditCard = data.datas[0].creditCard;
					promptTime = data.datas[0].promptTime;
					authentication = data.datas[0].authentication;
					errorMessage = data.datas[0].errorMessage;
					enterpriseId = data.datas[0].enterpriseId;
					databind.fillForm($("#enterpriseDetail"), data.datas[0]);
					$.each($(".materialContent>div"), function() {
						var $this = $(this);
						var str = "<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + $(this).html() + "'><img src='/finance/api/v1.0/downloadFile.file?fileUuid=" + $(this).html() + "'/></a>"
						$(this).html(str);
					});
					tools.barcode($("#enterpriseDetail .barcode"), data.datas[0].enterpriseCode, "code128");
					databind.disableInput($(".enterpriseDetailContent"));
					
					$("#enterpriseDetail .data[name=creditLine]").html(tools.formatCurrency($("#enterpriseDetail .data[name=creditLine]").html()));
					$("#enterpriseDetail .data[name=creditAlready]").html(tools.formatCurrency($("#enterpriseDetail .data[name=creditAlready]").html()));
					$("#enterpriseDetail .data[name=creditRemaining]").html(tools.formatCurrency($("#enterpriseDetail .data[name=creditRemaining]").html()));
					$("#enterpriseDetail input[name=registeredCapital]").val(tools.formatCurrency($("#enterpriseDetail input[name=registeredCapital]").val()));
					
					if (data.datas[0].authentication == 3) {
						$(".downloadPoiDoc").show();
					} else {
						$(".downloadPoiDoc").hide();
					}
					
					
					$(".downloadPoiDoc").unbind("click").click(function(){
						document.getElementById("ifile1").src="/finance/api/v1.0/getPoiDoc.json?enterpriseId="+data.datas[0].enterpriseId;
					});
				} else {
//					base.alert(3, data.message);
				}
			}
		});
	}
	
	
	//查询印章详情
	var inquireSealDetail = function(sealType, callback) {
		base.fnAjax({
			action: "inquireSealDetail.json",
			async: false,
			oData: {
				enterpriseId: enterpriseId,
				sealType: sealType
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					if (data.datas[0] != null) {
						auditState1 = data.datas[0].auditState;
						id = data.datas[0].id;
						enabled = data.datas[0].enabled;
						modelType = data.datas[0].modelType;
						callback(data);
						
						$("#container3 .auditstate").html(constant.getValueByKey(18, data.datas[0].auditState))
						
						if(auditState1 == 0) { //1.未提交 -- 模板印章
							hideAuditButtion(true);
						} else if (auditState1 == 1) { //2.已提交 未审核
							if(modelType == 1) { //2.1 模板印章
								
							}else if (modelType == 2) { //2.2 图片印章
								$(".typeP1").hide();
								$(".typeP2").hide();
							}
							
							hideAuditButtion(false);
						} else if (auditState1 == 2 || auditState1 == 3 || auditState1 == 4 || auditState1 == 5) { // 3. 已提交 审核通过或审核拒绝或审核完成或重新制章
							if(modelType == 1) { //2.1 模板印章
								
							}else if (modelType == 2) { //2.2 图片印章
								$(".typeP1").hide();
								$(".typeP2").hide();
							}
							
							hideAuditButtion(true);
							//获取审核信息
							if(auditState1 == 2 || auditState1 == 4) {// 通过 或 完成 
								$("#clientManage_authentication .callBackSignature").css("display", "block");
							}
							
						}
						
						inquirySignatureCallbackRecord(null);
						$("#container3 input[name='hText']").val(data.datas[0].hText);
						$("#container3 input[name='qText']").val(data.datas[0].qText);
						if (data.datas.length > 0) {
							if (data.datas[0].data != "") {
								$("#imgLook").attr("src", data.datas[0].sealSrc);
							} else {
								previewEnterpriseTemplateSeal();
							}
						}else {
						}
					}
				
				} else {
//					base.alert(3, data.message);
				}
				
			}
		});
	}
	
	//审核样式
	var hideAuditButtion = function(b) {
		if(b) {
			$("#container3 .aggreButton").hide();
			$("#container3 .refuseButton").hide();
		}else {
			$("#container3 .aggreButton").show();
			$("#container3 .refuseButton").show();
		}
		$("#clientManage_authentication .callBackSignature").css("display", "none");
	}
	
	//实名认证样式
	var container3 = function() {
		$("#container3 .d2").css("background", "url(../../../res/png/tab_bg3.png) center bottom no-repeat");
		$(".container").addClass("none");
		$(".container1").addClass("none");
		$("#enterpriseDetail").addClass("none");
		$(".container2").removeClass("none");
		$(".enterpriseDetailInfo").css("color", "#000");
		$(".enterpriseDetailMaterial").css("color", "#000");
		$(".mySignatureInfo").css("color", "#000");
		$(".certification").css("color", "#ff7344");
	}
	
	//我的签章样式
	var mySignatureCss = function() {
		$("#enterpriseDetail .d2").css("background", "url(../../../res/png/tab_bg4.png) center bottom no-repeat");
		$(".container").addClass("none");
		$(".container1").addClass("none");
		$(".container2").addClass("none");
		$("#container3").removeClass("none");
		$(".enterpriseDetailInfo").css("color", "#000");
		$(".enterpriseDetailMaterial").css("color", "#000");
		$(".certification").css("color", "#000");
		$(".mySignatureInfo").css("color", "#ff7344");
	}
	
	//输入审核金额
	var playMoneyStateInfo = function() {
		var ii = layer.open({
			  title: '企业对公账号确认',
			  type: 1,
			  skin: 'layui-layer-rim', //加上边框
			  area: ['430px', '330px'], //宽高
			  content: html_playMoney,
			  btn: ['确定'],
			  yes: function(){
				  var cash = $("#cash").val();
				  if(cash == 0 || cash == "") { //输入审核金额失败
					  base.alert(2, "输入金额不能为0或空!");
					  return;
				  }
				  databind.submitDom($(".inputCashInfo"), function(){
					  layer.close(ii);
				  	  history.go(0);
				  	});
			  }
			});
		$(".inputCashInfo #depositBank").val(depositBank);
		$(".inputCashInfo #subbranch").val(subbranch);
		$(".inputCashInfo #creditCard").val(creditCard);
		$(".layui-layer-title").css({"text-align":"center","font-size":"30px","height":"60px","padding-top":"6px","padding-left":"50px","color":"red"});
		$(".layui-layer-btn0").css({"position":"relative","margin-top":"-60px","margin-right":"140px","width":"140px","height":"40px","text-align":"center","padding-top":"6px","font-size":"18px","background-color":"rgb(196,62,62)"});
	}
	
	//查询重新制章记录
	var inquirySignatureCallbackRecord = function(recordType) {
		var sealType = $("#clientManage_authentication input[name='sealType']").val();
		base.fnAjax({
			action: "inquirySignatureCallbackRecord.json",
			async: true,
			nocode: true,
			oData: {
				enterpriseId: enterpriseId,
				sealType: sealType,
				recordType: recordType
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					if(data.datas[0] != undefined) {
						var recordType = parseFloat(data.datas[0].recordType);
						console.log(recordType);
						if(recordType == 1) { //1：审核打回/2：审核拒绝/3：审核通过
							$("#clientManage_authentication .auditInfo").text("重新制章反馈信息：");
						}
						if(recordType == 2) {
							$("#clientManage_authentication .auditInfo").text("印章审核拒绝信息：");
						}
						if(recordType == 3) { 
							$("#clientManage_authentication .auditInfo").text("审核通过信息：");
						}
						databind.fillForm($(".sealSubmitInfo"), data.datas[0]);
					}
				}else {
					//
				}
			}
		})
	}
	
	//印章类型样式
	var changeCssSealType = function(dom,sealType) {
		$("#clientManage_authentication input[name=sealType]").val(sealType);
		dom.addClass("liCss");
		dom.siblings().removeClass("liCss");
		if(sealType == 1) { //法人印章
			$(".typeP1").hide();
			$(".typeP2").hide();
			//改变印章大小
			$("#imgLook").css({"width":"129px","height":"129px"});
			$(".divImg").css({"width":"160px","height":"160px"});
		}else {
			$(".typeP1").show();
			$(".typeP2").show();
			//改变印章大小
			$("#imgLook").css({"width":"159px","height":"159px"});
			$(".divImg").css({"width":"180px","height":"180px"});
		}
		
	}
	
	//及时生成印章
	var previewEnterpriseTemplateSeal = function() {
		var sealType = $("#clientManage_authentication input[name='sealType']").val();
		var hText = $("#clientManage_authentication input[name='hText']").val();
		var qText = $("#clientManage_authentication input[name='qText']").val();
		//校验
		if(hText.length > 8) {
			base.alert(2, "横向文不能超过8个汉字长度");
			return;
		}
		if(qText.length > 20) {
			base.alert(2, "下弦文过长");
			return;
		}
		
		base.fnAjax({
			action: "previewEnterpriseTemplateSeal.json",
			nocode: true,
			oData: {
				hText: hText,
				qText: qText,
				sealType: sealType,
				remark: "",
				enterpriseId: enterpriseId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$(".divImg").children("img").attr("src", data.datas[0].sealData);
				} else {
					base.alert(2, "印章预览失败");
				}
			}
		});
	};
	
	return {
		init: init
	};
});